package com.cykj.service.impl;

import com.cykj.dto.ResponseDTO;
import com.cykj.entity.OrderCountDO;
import com.cykj.entity.OrderDO;
import com.cykj.mapper.OrderMapper;
import com.cykj.service.IOrderService;
import com.cykj.vo.OrderVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Program: Mooc-Admin
 * @Package: com.cykj.service.impl
 * @Author: 张俊杰
 * @Create: 2025-07-10 13:42
 * @Description: TODO
 * @Vision: 1.0
 **/
@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public ResponseDTO getListOrder(OrderVO orderVO) {

        PageHelper.startPage(orderVO.getPageNum(), orderVO.getPageSize());

        List<OrderDO> orderList = orderMapper.getListOrder(orderVO);

        PageInfo<OrderDO> orderDOPageInfo = new PageInfo<>(orderList);

        return ResponseDTO.success(orderDOPageInfo);
    }

    @Override
    public ResponseDTO getOrderCount() {
        List<OrderCountDO> orderCount = orderMapper.getOrderCount();
        return ResponseDTO.success(orderCount);
    }
}
